// 登录框控制器
define('loginBoxController', ['angular','ngCookies'], function (angular) {
    var module = angular.module('controllers',['ngCookies']);
    module.controller('loginBoxController', ['$scope','$rootScope','$cookieStore','$location','loginServers', function ($scope,$rootScope,$cookieStore,$location,loginServers) {
        $scope.formData = {};
        $scope.processForm = function() {
        	var user=loginServers.login($scope.formData.account,$scope.formData.password);
        	user.then(function(data){
                console.log(data);
                if (!angular.equals({},data)) {
                    console.log("登录成功");
                    // var curUrl = $location.absUrl();
                    $location.path("/Notice/index");
                }else{
                    console.log("登录失败");
                    $scope.formData.error = '用户不存在！';
                }
                // $scope.user = data;
            },function(data){
                console.log("登录失败");   
                $scope.formData = {error: '用户不存在！'};
            });
        };
    }]);
});